
import 'package:casdon/core/logger/log.dart';
import 'package:casdon/core/network/business_exception.dart';
import 'package:casdon/modules/recipe/data/api/recipe_module_content_api.dart';
import 'package:casdon/modules/recipe/data/repository/recipe_repository.dart';

class RecipeModuleContentUsecase {
  final RecipeRepository _repository;

 const RecipeModuleContentUsecase(this._repository);

  Future<ResponseRecipeModuleContentApi> execute(RequestRecipeModuleContentApi request) async {
    try {
      var ret = await _repository.getRecipeModuleContent(request);
       ret ??= ResponseRecipeModuleContentApi(0, []);
       return ret;
    } on BusinessException {
      rethrow;
    } catch (e) {
      Log.e("RecipeModuleContentUsecase 失败", e.toString(), StackTrace.current);
      throw Exception("RecipeModuleContentUsecase 失败");
    }
  }
}